home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_07 / plauger / isgstrm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-03  |  571 b   |  28 lines

  1. // isgstream -- istream::get(streambuf&, char)
  2. #include <istream>
  3.  
  4. istream& istream::get(streambuf&sb, char delim)
  5.     {    // get into streambuf until delimiter
  6.     _Chcount = 0;
  7.     _TRY_IO_BEGIN
  8.     if (ipfx(1))
  9.         {    // copy characters until failure
  10.         int ch;
  11.         for (; (ch = rdbuf()->sbumpc()) != EOF; ++_Chcount)
  12.             _TRY_BEGIN
  13.                 if (ch == delim || sb.sputc(ch) == EOF)
  14.                     break;
  15.             _CATCH_ALL
  16.                 break;
  17.             _CATCH_END
  18.         if (ch != EOF)
  19.             rdbuf()->sputbackc(ch);
  20.         }
  21.     if (_Chcount == 0)
  22.         setstate(failbit);
  23.     isfx();
  24.     _CATCH_IO_END
  25.     return (*this);
  26.     }
  27.  
  28.